# 列表的定义
my_list = [1, 2, 3, 4]

# 元组的定义
my_tuple = (1, 2, 3, 4)
print(my_tuple)
my_tuple = ()
print(my_tuple)
my_tuple = tuple()
print(my_tuple)

############ 注意########
my_tuple = ('1')
print(my_tuple, type(my_tuple))
my_tuple = ('1',)
print(my_tuple, type(my_tuple))

i_list = [1, 2, 3]
my_tuple = ('apple', 'banana', 'orange', 1, 3.14, False, i_list)
# # IndexError: tuple index out of range
# print(my_tuple, type(my_tuple))

## 切片
# my_tuple[start:end:step]




### 索引
my_tuple = ('apple', 'banana', 'orange', 1, 3.14, False, i_list)
print(my_tuple[0])
print(my_tuple[-1])
# # 下标越界
# print(my_tuple[-100])



### 元组的不可变性
# 元组是不可变的：
my_tuple = ('apple', 'banana', 'orange', 1, 3.14, False, i_list)
# # TypeError: 'tuple' object does not support item assignment
# my_tuple[0] = 'pear'

print(my_tuple[-1])
# TypeError: 'tuple' object does not support item assignment
# my_tuple[-1] = '西瓜'
my_tuple[-1][0] = '西瓜'
print(my_tuple)

### 统计功能
my_tuple = ('apple', 'banana', 'orange', 1, 3.14, False, i_list)
len(my_tuple)
my_tuple.count('apple')
my_tuple.index('apple')

## 遍历元组
my_tuple = ('apple', 'orange', 'banana', 'Orange', 'banana', 'banana')
for i in enumerate(my_tuple):
    print(i)
print(dir(tuple))

### 成员关系
singer = ('李圣杰', '张韶涵', '汪峰')
print('林志炫' in singer)
print('张韶涵' in singer)
print('张韶涵' not in singer)
print('林志炫' not in singer)


# * 用户检测(无限次)
#     * 欢迎语：”欢迎使用用户检测系统“
#     * 定义一个用户列表
#     * 提醒用户输入用户名
#     * 判断用户是否存在
#     * 当用户输入的值为‘quit’的时候，退出查找
